﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Check;
using TG;
using pay.Entity;
using pay.BLL;
using System.Text;

public partial class tg_pop2 : System.Web.UI.Page
{
    public string str_sb = "";
    public string uname = "";
    public string tel = "";
    public string buylist = "";
    public string LinkMan = "";
    public string Msg = "";
    public string paytel = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["EmoneyShopCard"] == null)
            {
                Response.Redirect("index.html");
            }
            if (string.IsNullOrEmpty(Request["uname"]) && Session["uname"]==null)
            {
                Response.Write("<script>alert('用户姓名不能为空!'); this.history.back(-1);</script>");
                return;
            }
            if (string.IsNullOrEmpty(Request["tel"]) && Session["tel"]==null)
            {
                Response.Write("<script>alert('联系电话不能为空！!'); this.history.back(-1);</script>");
                return;
            }
            string reg_uname = string.IsNullOrEmpty(Request["uname"])?"":Request["uname"].ToString().Trim().Replace(" ", "");
            if (string.IsNullOrEmpty(reg_uname))
            {
                reg_uname = Session["uname"].ToString();
            }
            bool flag0 = Verification.IsTszfc(reg_uname);
            if (flag0 == true)
            {
                uname = reg_uname;
            }
            else
            {
                Response.Write("<script>alert('用户姓名包含非法字符，请重新输入!'); this.history.back(-1);</script>");
                return;
            }
            string reg_tel = Request["tel"];
            if (string.IsNullOrEmpty(reg_tel))
            {
                reg_tel = Session["tel"].ToString();
            }
            TGDal tgDal = new TGDal();
            if (tgDal.GetTgByMobile(reg_tel) != null)
            {
                Response.Write("<script>alert('您的手机号已经参加团购了!'); this.history.back(-1);</script>");
                return;
            }
            bool flag = Verification.IsMobileNum(reg_tel);
            bool flag1 = Verification.IsPhoneNum(reg_tel);
            if (flag == true || flag1 == true)
            {
                tel = reg_tel;
                paytel = tel.Substring(0, 3) + "****" + tel.Substring(7, 4);
            }
            else
            {
                Response.Write("<script>alert('请输入正确的电话或手机号码,例如:13916752109或0712-3614072'); this.history.back(-1);</script>");
                return;
            }
            LinkMan = getLinkMan();
            Session["uname"] = uname;
            Session["tel"] = tel;
            Session["Linkman"] = LinkMan;
        }
    }

    public string getLinkMan()
    {
        if (Request["LinkMan"] != null)
        {
            LinkMan = Request["LinkMan"].ToString();
        }
        return LinkMan;
    }
}